const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '随机值',
			prop: 'randomNo',
		},
		{
			label: '规则名称',
			prop: 'ruleName',
		},
		// {
		// 	label: '规则内容',
		// 	prop: 'ruleContent',
		// },
		{
			label: '创建人姓名',
			prop: 'createUserName',
		},
		{
			label: '新增时间',
			prop: 'createTime',
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const formConfig = {
	label: '数据管理设置',
	prop: 'base0',
	inline: false,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '规则名称',
			prop: 'ruleName',
			type: 'input',
			span: 8,
			rules: [{ required: true, message: '请填写规则名称' }],
		},
		{
			label: '规则内容',
			prop: 'ruleContent',
			
			type: 'dynamic',
			span: 24,
			column: [
				{
					label: '通知渠道',
					prop: 'informChannel',
					type: 'select',
					dicData: [
						{ label: 'web平台', value: 0 },
						{ label: 'app', value: 1 },
						{ label: '短信', value: 2 },
						{ label: '邮箱', value: 3 },
					],
					multiple: false,
					rules: [{ required: true, message: '请选择通知渠道' }],
				},
				{
					label:'提前通知天数',
					prop:'aheadInform',
					rules: [{ required: true, message: '请填写提前通知天数' }],
				},
				{
					label:'是否精确',
					prop:'timePrecise',
					type:'select',
					defaultValue:0,
					disabled:true,
					tip:"'是'表示精确到年月日时分秒，'否'表示精确到年月日,默认选择否",
					dicData:[
						{label:'否',value:0},
						{label:'是',value:1},
					],
					rules: [{ required: true, message: '请填写选择是否精确' }],
				}
			],
		},
	],
}
const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	column: [
		{
			label: '随机值',
			prop: 'randomNo',
			type: 'input',
			span: 6,
		},
		{
			label: '规则名称',
			prop: 'ruleName',
			type: 'input',
			span: 6,
		},
		// {
		// 	label: '规则内容',
		// 	prop: 'ruleContent',
		// 	type: 'input',
		// 	span: 6,
		// },
	],
}
export const baseConfig: any = {
	pageName: '数据过期提醒规则',
	addLabel: '添加',
	dictcodes: [],
	rowKey: 'id',
	tipLabel: 'ruleName',
	api: {
		index: 'view_dataExpireRemindRule_page',
		add: 'view_dataExpireRemindRule_add',
		edit: 'view_dataExpireRemindRule_edit',
		delete: 'view_dataExpireRemindRule_del',
	},
	auth: {
		index: 'view_dataExpireRemindRule_page',
		add: 'view_dataExpireRemindRule_add',
		edit: 'view_dataExpireRemindRule_edit',
		delete: 'view_dataExpireRemindRule_del',
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'view_dataManagementSettings_edit',
			text: true,
			show: true,
		},
		{
			icon: 'delete',
			label: '删除',
			type: 'primary',
			operate: 'delete',
			auth: 'view_dataManagementSettings_del',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	searchConfig,
	tableConfig,
	formConfig,
	saveFormate: async (form) => {
		return new Promise((resolve, reject) => {
			form.ruleContent = JSON.stringify(form.ruleContent)
			resolve({
				...form
			})
		})
	},
	onLoadFormate: async (arr) => {
		const tableData = arr.map((item) => {
			if(item.ruleContent){
				item.ruleContent = JSON.parse(item.ruleContent)
			}
			console.log('所有数据',item)
			return {
				...item,
			}
		})
		console.log(tableData, 'tableData')
		return Promise.resolve(Object.freeze(tableData))
	}
}
